-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add next token #17
Add next token #17
Conversation
src/lexer/lex.c
Outdated
char prev; | ||
if ((cur = fgetc(l->fp)) != EOF) { | ||
prev = cur; | ||
if (!(cur == ' ' || cur == '/')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about tabs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted -- Fixing now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be resolved.
src/lexer/lex.c
Outdated
} else { | ||
return -1; // file done, no more tokens | ||
} | ||
// read each character from the file until EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having a bit of trouble understanding what this section of code (until the end of the file) is doing, to be honest. Does this correctly handle a case like
/* Comment
number one*/ /* Comment number two*/ int x = 3;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is just a check to make sure the file is not already over. If EOF is the next character, then it returns -1 meaning there are no tokens to get.
Adds support for jumping to next token (avoiding block comments and single line comments). Also skips leading spaces.
Essentially, this code works by stopping on the first character that is not considered to be a block comment.
Possible issue: May be missing an edge case where the wrong place is returned in the case of
#include <folder/file>
. Will fix later if confirmed. Fixed.